package com.derbysoft.lowcostadapter.dswitch3.translate.impl;

import com.derbysoft.dswitch.dto.hotel.avail.FreeMealDTO;

import java.util.HashMap;
import java.util.Map;

public enum DSwitch3MealBasis {
    ALL_INCLUSIVE(1, FreeMealDTO.FreeMealType.BREAKFAST_AND_LUNCH_AND_DINNER, "All Inclusive"),

    BED_AND_BREAKFAST(3, FreeMealDTO.FreeMealType.BREAKFAST, "Bed & Breakfast"),

    FULL_BOARD(5, FreeMealDTO.FreeMealType.BREAKFAST_AND_LUNCH_AND_DINNER, "Full Board"),

    HALF_BOARD(7, FreeMealDTO.FreeMealType.BREAKFAST_AND_DINNER, "Half Board"),

    ROOM_ONLY(8, FreeMealDTO.FreeMealType.NONE, "Room Only"),

    SELF_CATERING(9, FreeMealDTO.FreeMealType.DESCRIPTION, "Self Catering"),

    UNKNOWN(-1, FreeMealDTO.FreeMealType.DESCRIPTION, "");

    private int mealBaseID;
    private FreeMealDTO.FreeMealType freeMealType;
    private String description;

    private static Map<Integer, DSwitch3MealBasis> mealBasisMap = createMealBasisMap();

    private static Map<Integer, DSwitch3MealBasis> createMealBasisMap() {
        HashMap<Integer, DSwitch3MealBasis> mealBasisHashMap = new HashMap<Integer, DSwitch3MealBasis>();
        for (DSwitch3MealBasis mealBasis : DSwitch3MealBasis.values()) {
            mealBasisHashMap.put(mealBasis.getMealBaseID(), mealBasis);
        }
        return mealBasisHashMap;
    }

    DSwitch3MealBasis(int mealBaseID, FreeMealDTO.FreeMealType freeMealType, String description) {
        this.mealBaseID = mealBaseID;
        this.freeMealType = freeMealType;
        this.description = description;
    }

    public static DSwitch3MealBasis fromID(int mealBasisID) {
        if (mealBasisMap.containsKey(mealBasisID)) {
            return mealBasisMap.get(mealBasisID);
        }

        return UNKNOWN;
    }

    public int getMealBaseID() {
        return mealBaseID;
    }

    public FreeMealDTO.FreeMealType getFreeMealType() {
        return freeMealType;
    }

    public String getDescription() {
        return description;
    }
}